package com.bsoft.gol.editor.service.impl;

//import ctd.util.BeanUtils;
import ctd.util.JSONUtils;
import ctd.util.annotation.RpcService;
import ctd.util.exception.CodedBaseRuntimeException;
import com.bsoft.gol.editor.dao.ControlReportEntityDAO;
import com.bsoft.gol.editor.dao.DiagnosisListDAO;
import hcn.util.BaseResponse;
import com.bsoft.gol.editor.editor.ControlReportEntity;
import com.bsoft.gol.editor.editor.DiagnosisList;
import com.bsoft.gol.editor.editor.request.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import com.bsoft.gol.editor.service.ControlReportService;

import java.util.List;

/**
 * 表单编辑器 his 检查 检验 医嘱 报告到日
 *
 * @author lxy
 * @date 2019/6/26
 */
@Service("controlReportService")
public class ControlReportServiceImpl implements ControlReportService {
    private static Logger logger = LoggerFactory.getLogger(ControlReportServiceImpl.class);
    @Autowired
    private ControlReportEntityDAO controlReportEntityDAO;

    @Autowired
    private DiagnosisListDAO diagnosisListDAO;


    @Override
    public BaseResponse<List<ControlReportEntity>> queryControlReportList(ControlReportEntityReq req) {
        BaseResponse<List<ControlReportEntity>> baseResponse = new BaseResponse<>();

        List<ControlReportEntity> controlReportEntityList = controlReportEntityDAO.queryControlReportEntityList(req.getMaxSize());

        for (ControlReportEntity controlReportEntity : controlReportEntityList) {
            List<DiagnosisList> diagnosisList = diagnosisListDAO.queryDiagnosisListByReportId(controlReportEntity.getReportId());
            if (diagnosisList != null) {
                controlReportEntity.setDiagnosisList(diagnosisList);
            }
        }
        baseResponse.setData(controlReportEntityList);
        return baseResponse;
    }

    @Override
    public BaseResponse updateControlReportList(@RequestBody List<String> req) {
        controlReportEntityDAO.updateControlReportEntityList(req);
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setCode(200);
        return baseResponse;
    }
}
